//
//  HRRecommendTableViewCell.m
//  Hear
//
//  Created by mac on 2018/4/20.
//  Copyright © 2018年 mac. All rights reserved.
//

#import "HRRecommendTableViewCell.h"
#import "HRHearRecommendTopView.h"
#import "HRHearRecommendRightView.h"
#import "HRHearRecommendAnswererView.h"

@interface HRRecommendTableViewCell()
@property(nonatomic, strong)HRHearRecommendTopView *hrhearRecommendTopView;
@property(nonatomic, strong)HRHearRecommendRightView *hrhearRecommendRightView;
@property(nonatomic, strong)HRHearRecommendAnswererView *hrhearRecommendAnswererView;
@property(nonatomic, strong)UIButton *playerBtn;
@property(nonatomic, assign)BOOL selected;

@end

@implementation HRRecommendTableViewCell

-(id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self == [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        [self setupView];
        
    }
    return self;
}

#pragma mark ----- 设置UI布局
-(void)setupView
{    
    UIImageView *backGroundImageView = [[UIImageView alloc] init];
    [backGroundImageView setImage:[UIImage imageNamed:@"bg背景"]];
    [self addSubview:backGroundImageView];
//    [backGroundImageView mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.top.mas_equalTo(self.mas_top).offset(0);
//        make.left.mas_equalTo(self.mas_left).offset(0);
//        make.right.mas_equalTo(self.mas_right).offset(0);
//        make.bottom.mas_equalTo(self.mas_bottom).offset(0);
//    }];
    [backGroundImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.mas_equalTo(self);
    }];
    UIImageView *maskImageView = [[UIImageView alloc] init];
    [maskImageView setImage:[UIImage imageNamed:@"背景蒙版"]];
    [backGroundImageView addSubview:maskImageView];
    [maskImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.mas_equalTo(backGroundImageView);
    }];
    
    _hrhearRecommendTopView = [[HRHearRecommendTopView alloc] init];
    [self addSubview:_hrhearRecommendTopView];
    [_hrhearRecommendTopView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.mas_top).offset(22 * scaleHeight);
        make.left.mas_equalTo(self.mas_left).offset(13 * scaleWidth);
        make.right.mas_equalTo(self.mas_right).offset(-13 * scaleWidth);
        make.height.mas_equalTo(122 * scaleHeight);
    }];
    
    _playerBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [_playerBtn setBackgroundImage:[UIImage imageNamed:@"暂停"] forState:UIControlStateNormal];
    [_playerBtn addTarget:self action:@selector(playRecord:) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:_playerBtn];
    [_playerBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.center.mas_equalTo(self);
        make.width.mas_equalTo(70 * scaleWidth);
        make.height.mas_equalTo(70 * scaleWidth);
    }];
    
    _hrhearRecommendRightView = [[HRHearRecommendRightView alloc] init];
    [self addSubview:_hrhearRecommendRightView];
    [_hrhearRecommendRightView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(_hrhearRecommendTopView.mas_bottom).offset(35 * scaleHeight);
        make.right.mas_equalTo(_hrhearRecommendTopView.mas_right).offset(-7 * scaleWidth);
        make.left.mas_equalTo(self.mas_left).offset(315 * scaleWidth);
        make.bottom.mas_equalTo(self.mas_bottom).offset(-97 * scaleHeight);
    }];
    
    _hrhearRecommendAnswererView = [[HRHearRecommendAnswererView alloc] init];
    [self addSubview:_hrhearRecommendAnswererView];
    [_hrhearRecommendAnswererView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.mas_equalTo(self.mas_bottom).offset(-30 * scaleHeight);
        make.left.mas_equalTo(self.mas_left).offset(25 * scaleWidth);
        make.height.mas_equalTo(45 * scaleHeight);
    }];
}

-(void)playRecord:(UIButton *)btn
{
    NSLog(@"playRecord  -=-=-=-=-=-=-=-=-= ");
    btn.selected = !btn.selected;
    WeakSelf
    if (weakSelf.playRecorderBlock) {
        weakSelf.playRecorderBlock(btn.selected);
    }
}

//-(void)setModel:(HRRecommendModel *)model
//{
//    _hrhearRecommendTopView.topicLabel.text = model.QuestionText;
//    [_hrhearRecommendRightView.topicOwnerBtn setBackgroundImageWithURL:[NSURL URLWithString:model.MasterUserPictureName] forState:UIControlStateNormal placeholder:[UIImage imageNamed:@""]];
//
//    _hrhearRecommendRightView.likeNumLabel.text = [NSString stringWithFormat:@"%d",model.LikeCount];
//    _hrhearRecommendRightView.messageNumLabel.text = [NSString stringWithFormat:@"%d",model.CommentCount];
////    _hrhearRecommendRightView.forwardNumLabel.text = [NSString stringWithFormat:@"%d",model.]
//    [_hrhearRecommendAnswererView.answererHeadBtn setBackgroundImageWithURL:[NSURL URLWithString:model.UserPictureName] forState:UIControlStateNormal placeholder:nil];
//    _hrhearRecommendAnswererView.answererNameLabel.text = model.NickName;
//    _hrhearRecommendAnswererView.answererAgeLabel.text = [NSString stringWithFormat:@"%@",model.Age];
//    if (model.Sex ==1){
//        _hrhearRecommendAnswererView.answererSexImageView.image = [UIImage imageNamed:@"男"];
//    }
//    else
//    {
//        _hrhearRecommendAnswererView.answererSexImageView.image = [UIImage imageNamed:@"女"];
//
//    }
//
//}

- (void)awakeFromNib {
    [super awakeFromNib];
    
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
